<?php


abstract class BaseRingtonePeer {

	
	const DATABASE_NAME = 'propel';

	
	const TABLE_NAME = 'ringtone';

	
	const CLASS_DEFAULT = 'lib.model.Ringtone';

	
	const NUM_COLUMNS = 22;

	
	const NUM_LAZY_LOAD_COLUMNS = 0;


	
	const ID = 'ringtone.ID';

	
	const NAME = 'ringtone.NAME';

	
	const AVATAR_PATH = 'ringtone.AVATAR_PATH';

	
	const FILE_PATH_MP3 = 'ringtone.FILE_PATH_MP3';

	
	const FILE_PATH_WAV = 'ringtone.FILE_PATH_WAV';

	
	const DURATION = 'ringtone.DURATION';

	
	const CATEGORY_ID = 'ringtone.CATEGORY_ID';

	
	const CREATOR_ID = 'ringtone.CREATOR_ID';

	
	const CREATOR_NAME = 'ringtone.CREATOR_NAME';

	
	const CREATED_DATETIME = 'ringtone.CREATED_DATETIME';

	
	const RT_STATUS = 'ringtone.RT_STATUS';

	
	const RBT_STATUS = 'ringtone.RBT_STATUS';

	
	const COMPOSER_ID = 'ringtone.COMPOSER_ID';

	
	const COMPOSER_NAME = 'ringtone.COMPOSER_NAME';

	
	const COMPOSED_BY_USER = 'ringtone.COMPOSED_BY_USER';

	
	const CHECKNUM = 'ringtone.CHECKNUM';

	
	const TOTAL_SET = 'ringtone.TOTAL_SET';

	
	const TOTAL_DOWNLOAD = 'ringtone.TOTAL_DOWNLOAD';

	
	const BONUS_SET = 'ringtone.BONUS_SET';

	
	const BONUS_DOWNLOAD = 'ringtone.BONUS_DOWNLOAD';

	
	const UPDATE_TYPE = 'ringtone.UPDATE_TYPE';

	
	const LAST_UPDATE_DATETIME = 'ringtone.LAST_UPDATE_DATETIME';

	
	private static $phpNameMap = null;


	
	private static $fieldNames = array (
		BasePeer::TYPE_PHPNAME => array ('Id', 'Name', 'AvatarPath', 'FilePathMp3', 'FilePathWav', 'Duration', 'CategoryId', 'CreatorId', 'CreatorName', 'CreatedDatetime', 'RtStatus', 'RbtStatus', 'ComposerId', 'ComposerName', 'ComposedByUser', 'Checknum', 'TotalSet', 'TotalDownload', 'BonusSet', 'BonusDownload', 'UpdateType', 'LastUpdateDatetime', ),
		BasePeer::TYPE_COLNAME => array (RingtonePeer::ID, RingtonePeer::NAME, RingtonePeer::AVATAR_PATH, RingtonePeer::FILE_PATH_MP3, RingtonePeer::FILE_PATH_WAV, RingtonePeer::DURATION, RingtonePeer::CATEGORY_ID, RingtonePeer::CREATOR_ID, RingtonePeer::CREATOR_NAME, RingtonePeer::CREATED_DATETIME, RingtonePeer::RT_STATUS, RingtonePeer::RBT_STATUS, RingtonePeer::COMPOSER_ID, RingtonePeer::COMPOSER_NAME, RingtonePeer::COMPOSED_BY_USER, RingtonePeer::CHECKNUM, RingtonePeer::TOTAL_SET, RingtonePeer::TOTAL_DOWNLOAD, RingtonePeer::BONUS_SET, RingtonePeer::BONUS_DOWNLOAD, RingtonePeer::UPDATE_TYPE, RingtonePeer::LAST_UPDATE_DATETIME, ),
		BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'avatar_path', 'file_path_mp3', 'file_path_wav', 'duration', 'category_id', 'creator_id', 'creator_name', 'created_datetime', 'rt_status', 'rbt_status', 'composer_id', 'composer_name', 'composed_by_user', 'checknum', 'total_set', 'total_download', 'bonus_set', 'bonus_download', 'update_type', 'last_update_datetime', ),
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, )
	);

	
	private static $fieldKeys = array (
		BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Name' => 1, 'AvatarPath' => 2, 'FilePathMp3' => 3, 'FilePathWav' => 4, 'Duration' => 5, 'CategoryId' => 6, 'CreatorId' => 7, 'CreatorName' => 8, 'CreatedDatetime' => 9, 'RtStatus' => 10, 'RbtStatus' => 11, 'ComposerId' => 12, 'ComposerName' => 13, 'ComposedByUser' => 14, 'Checknum' => 15, 'TotalSet' => 16, 'TotalDownload' => 17, 'BonusSet' => 18, 'BonusDownload' => 19, 'UpdateType' => 20, 'LastUpdateDatetime' => 21, ),
		BasePeer::TYPE_COLNAME => array (RingtonePeer::ID => 0, RingtonePeer::NAME => 1, RingtonePeer::AVATAR_PATH => 2, RingtonePeer::FILE_PATH_MP3 => 3, RingtonePeer::FILE_PATH_WAV => 4, RingtonePeer::DURATION => 5, RingtonePeer::CATEGORY_ID => 6, RingtonePeer::CREATOR_ID => 7, RingtonePeer::CREATOR_NAME => 8, RingtonePeer::CREATED_DATETIME => 9, RingtonePeer::RT_STATUS => 10, RingtonePeer::RBT_STATUS => 11, RingtonePeer::COMPOSER_ID => 12, RingtonePeer::COMPOSER_NAME => 13, RingtonePeer::COMPOSED_BY_USER => 14, RingtonePeer::CHECKNUM => 15, RingtonePeer::TOTAL_SET => 16, RingtonePeer::TOTAL_DOWNLOAD => 17, RingtonePeer::BONUS_SET => 18, RingtonePeer::BONUS_DOWNLOAD => 19, RingtonePeer::UPDATE_TYPE => 20, RingtonePeer::LAST_UPDATE_DATETIME => 21, ),
		BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'avatar_path' => 2, 'file_path_mp3' => 3, 'file_path_wav' => 4, 'duration' => 5, 'category_id' => 6, 'creator_id' => 7, 'creator_name' => 8, 'created_datetime' => 9, 'rt_status' => 10, 'rbt_status' => 11, 'composer_id' => 12, 'composer_name' => 13, 'composed_by_user' => 14, 'checknum' => 15, 'total_set' => 16, 'total_download' => 17, 'bonus_set' => 18, 'bonus_download' => 19, 'update_type' => 20, 'last_update_datetime' => 21, ),
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, )
	);

	
	public static function getMapBuilder()
	{
		include_once 'lib/model/map/RingtoneMapBuilder.php';
		return BasePeer::getMapBuilder('lib.model.map.RingtoneMapBuilder');
	}
	
	public static function getPhpNameMap()
	{
		if (self::$phpNameMap === null) {
			$map = RingtonePeer::getTableMap();
			$columns = $map->getColumns();
			$nameMap = array();
			foreach ($columns as $column) {
				$nameMap[$column->getPhpName()] = $column->getColumnName();
			}
			self::$phpNameMap = $nameMap;
		}
		return self::$phpNameMap;
	}
	
	static public function translateFieldName($name, $fromType, $toType)
	{
		$toNames = self::getFieldNames($toType);
		$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
		if ($key === null) {
			throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
		}
		return $toNames[$key];
	}

	

	static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
	{
		if (!array_key_exists($type, self::$fieldNames)) {
			throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
		}
		return self::$fieldNames[$type];
	}

	
	public static function alias($alias, $column)
	{
		return str_replace(RingtonePeer::TABLE_NAME.'.', $alias.'.', $column);
	}

	
	public static function addSelectColumns(Criteria $criteria)
	{

		$criteria->addSelectColumn(RingtonePeer::ID);

		$criteria->addSelectColumn(RingtonePeer::NAME);

		$criteria->addSelectColumn(RingtonePeer::AVATAR_PATH);

		$criteria->addSelectColumn(RingtonePeer::FILE_PATH_MP3);

		$criteria->addSelectColumn(RingtonePeer::FILE_PATH_WAV);

		$criteria->addSelectColumn(RingtonePeer::DURATION);

		$criteria->addSelectColumn(RingtonePeer::CATEGORY_ID);

		$criteria->addSelectColumn(RingtonePeer::CREATOR_ID);

		$criteria->addSelectColumn(RingtonePeer::CREATOR_NAME);

		$criteria->addSelectColumn(RingtonePeer::CREATED_DATETIME);

		$criteria->addSelectColumn(RingtonePeer::RT_STATUS);

		$criteria->addSelectColumn(RingtonePeer::RBT_STATUS);

		$criteria->addSelectColumn(RingtonePeer::COMPOSER_ID);

		$criteria->addSelectColumn(RingtonePeer::COMPOSER_NAME);

		$criteria->addSelectColumn(RingtonePeer::COMPOSED_BY_USER);

		$criteria->addSelectColumn(RingtonePeer::CHECKNUM);

		$criteria->addSelectColumn(RingtonePeer::TOTAL_SET);

		$criteria->addSelectColumn(RingtonePeer::TOTAL_DOWNLOAD);

		$criteria->addSelectColumn(RingtonePeer::BONUS_SET);

		$criteria->addSelectColumn(RingtonePeer::BONUS_DOWNLOAD);

		$criteria->addSelectColumn(RingtonePeer::UPDATE_TYPE);

		$criteria->addSelectColumn(RingtonePeer::LAST_UPDATE_DATETIME);

	}

	const COUNT = 'COUNT(ringtone.ID)';
	const COUNT_DISTINCT = 'COUNT(DISTINCT ringtone.ID)';

	
	public static function doCount(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(RingtonePeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(RingtonePeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$rs = RingtonePeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}
	
	public static function doSelectOne(Criteria $criteria, $con = null)
	{
		$critcopy = clone $criteria;
		$critcopy->setLimit(1);
		$objects = RingtonePeer::doSelect($critcopy, $con);
		if ($objects) {
			return $objects[0];
		}
		return null;
	}
	
	public static function doSelect(Criteria $criteria, $con = null)
	{
		return RingtonePeer::populateObjects(RingtonePeer::doSelectRS($criteria, $con));
	}
	
	public static function doSelectRS(Criteria $criteria, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		if (!$criteria->getSelectColumns()) {
			$criteria = clone $criteria;
			RingtonePeer::addSelectColumns($criteria);
		}

				$criteria->setDbName(self::DATABASE_NAME);

						return BasePeer::doSelect($criteria, $con);
	}
	
	public static function populateObjects(ResultSet $rs)
	{
		$results = array();
	
				$cls = RingtonePeer::getOMClass();
		$cls = Propel::import($cls);
				while($rs->next()) {
		
			$obj = new $cls();
			$obj->hydrate($rs);
			$results[] = $obj;
			
		}
		return $results;
	}

	
	public static function doCountJoinUser(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(RingtonePeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(RingtonePeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$criteria->addJoin(RingtonePeer::CREATOR_ID, UserPeer::ID);

		$rs = RingtonePeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}


	
	public static function doCountJoinRingtoneCategory(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(RingtonePeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(RingtonePeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$criteria->addJoin(RingtonePeer::CATEGORY_ID, RingtoneCategoryPeer::ID);

		$rs = RingtonePeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}


	
	public static function doSelectJoinUser(Criteria $c, $con = null)
	{
		$c = clone $c;

				if ($c->getDbName() == Propel::getDefaultDB()) {
			$c->setDbName(self::DATABASE_NAME);
		}

		RingtonePeer::addSelectColumns($c);
		$startcol = (RingtonePeer::NUM_COLUMNS - RingtonePeer::NUM_LAZY_LOAD_COLUMNS) + 1;
		UserPeer::addSelectColumns($c);

		$c->addJoin(RingtonePeer::CREATOR_ID, UserPeer::ID);
		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = RingtonePeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);

			$omClass = UserPeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj2 = new $cls();
			$obj2->hydrate($rs, $startcol);

			$newObject = true;
			foreach($results as $temp_obj1) {
				$temp_obj2 = $temp_obj1->getUser(); 				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
										$temp_obj2->addRingtone($obj1); 					break;
				}
			}
			if ($newObject) {
				$obj2->initRingtones();
				$obj2->addRingtone($obj1); 			}
			$results[] = $obj1;
		}
		return $results;
	}


	
	public static function doSelectJoinRingtoneCategory(Criteria $c, $con = null)
	{
		$c = clone $c;

				if ($c->getDbName() == Propel::getDefaultDB()) {
			$c->setDbName(self::DATABASE_NAME);
		}

		RingtonePeer::addSelectColumns($c);
		$startcol = (RingtonePeer::NUM_COLUMNS - RingtonePeer::NUM_LAZY_LOAD_COLUMNS) + 1;
		RingtoneCategoryPeer::addSelectColumns($c);

		$c->addJoin(RingtonePeer::CATEGORY_ID, RingtoneCategoryPeer::ID);
		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = RingtonePeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);

			$omClass = RingtoneCategoryPeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj2 = new $cls();
			$obj2->hydrate($rs, $startcol);

			$newObject = true;
			foreach($results as $temp_obj1) {
				$temp_obj2 = $temp_obj1->getRingtoneCategory(); 				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
										$temp_obj2->addRingtone($obj1); 					break;
				}
			}
			if ($newObject) {
				$obj2->initRingtones();
				$obj2->addRingtone($obj1); 			}
			$results[] = $obj1;
		}
		return $results;
	}


	
	public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null)
	{
		$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(RingtonePeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(RingtonePeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$criteria->addJoin(RingtonePeer::CREATOR_ID, UserPeer::ID);

		$criteria->addJoin(RingtonePeer::CATEGORY_ID, RingtoneCategoryPeer::ID);

		$rs = RingtonePeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}


	
	public static function doSelectJoinAll(Criteria $c, $con = null)
	{
		$c = clone $c;

				if ($c->getDbName() == Propel::getDefaultDB()) {
			$c->setDbName(self::DATABASE_NAME);
		}

		RingtonePeer::addSelectColumns($c);
		$startcol2 = (RingtonePeer::NUM_COLUMNS - RingtonePeer::NUM_LAZY_LOAD_COLUMNS) + 1;

		UserPeer::addSelectColumns($c);
		$startcol3 = $startcol2 + UserPeer::NUM_COLUMNS;

		RingtoneCategoryPeer::addSelectColumns($c);
		$startcol4 = $startcol3 + RingtoneCategoryPeer::NUM_COLUMNS;

		$c->addJoin(RingtonePeer::CREATOR_ID, UserPeer::ID);

		$c->addJoin(RingtonePeer::CATEGORY_ID, RingtoneCategoryPeer::ID);

		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = RingtonePeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);


					
			$omClass = UserPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj2 = new $cls();
			$obj2->hydrate($rs, $startcol2);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj2 = $temp_obj1->getUser(); 				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
					$temp_obj2->addRingtone($obj1); 					break;
				}
			}

			if ($newObject) {
				$obj2->initRingtones();
				$obj2->addRingtone($obj1);
			}


					
			$omClass = RingtoneCategoryPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj3 = new $cls();
			$obj3->hydrate($rs, $startcol3);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj3 = $temp_obj1->getRingtoneCategory(); 				if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) {
					$newObject = false;
					$temp_obj3->addRingtone($obj1); 					break;
				}
			}

			if ($newObject) {
				$obj3->initRingtones();
				$obj3->addRingtone($obj1);
			}

			$results[] = $obj1;
		}
		return $results;
	}


	
	public static function doCountJoinAllExceptUser(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(RingtonePeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(RingtonePeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$criteria->addJoin(RingtonePeer::CATEGORY_ID, RingtoneCategoryPeer::ID);

		$rs = RingtonePeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}


	
	public static function doCountJoinAllExceptRingtoneCategory(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(RingtonePeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(RingtonePeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$criteria->addJoin(RingtonePeer::CREATOR_ID, UserPeer::ID);

		$rs = RingtonePeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}


	
	public static function doSelectJoinAllExceptUser(Criteria $c, $con = null)
	{
		$c = clone $c;

								if ($c->getDbName() == Propel::getDefaultDB()) {
			$c->setDbName(self::DATABASE_NAME);
		}

		RingtonePeer::addSelectColumns($c);
		$startcol2 = (RingtonePeer::NUM_COLUMNS - RingtonePeer::NUM_LAZY_LOAD_COLUMNS) + 1;

		RingtoneCategoryPeer::addSelectColumns($c);
		$startcol3 = $startcol2 + RingtoneCategoryPeer::NUM_COLUMNS;

		$c->addJoin(RingtonePeer::CATEGORY_ID, RingtoneCategoryPeer::ID);


		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = RingtonePeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);

			$omClass = RingtoneCategoryPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj2  = new $cls();
			$obj2->hydrate($rs, $startcol2);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj2 = $temp_obj1->getRingtoneCategory(); 				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
					$temp_obj2->addRingtone($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj2->initRingtones();
				$obj2->addRingtone($obj1);
			}

			$results[] = $obj1;
		}
		return $results;
	}


	
	public static function doSelectJoinAllExceptRingtoneCategory(Criteria $c, $con = null)
	{
		$c = clone $c;

								if ($c->getDbName() == Propel::getDefaultDB()) {
			$c->setDbName(self::DATABASE_NAME);
		}

		RingtonePeer::addSelectColumns($c);
		$startcol2 = (RingtonePeer::NUM_COLUMNS - RingtonePeer::NUM_LAZY_LOAD_COLUMNS) + 1;

		UserPeer::addSelectColumns($c);
		$startcol3 = $startcol2 + UserPeer::NUM_COLUMNS;

		$c->addJoin(RingtonePeer::CREATOR_ID, UserPeer::ID);


		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = RingtonePeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);

			$omClass = UserPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj2  = new $cls();
			$obj2->hydrate($rs, $startcol2);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj2 = $temp_obj1->getUser(); 				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
					$temp_obj2->addRingtone($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj2->initRingtones();
				$obj2->addRingtone($obj1);
			}

			$results[] = $obj1;
		}
		return $results;
	}

	
	public static function getTableMap()
	{
		return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
	}

	
	public static function getOMClass()
	{
		return RingtonePeer::CLASS_DEFAULT;
	}

	
	public static function doInsert($values, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		if ($values instanceof Criteria) {
			$criteria = clone $values; 		} else {
			$criteria = $values->buildCriteria(); 		}

		$criteria->remove(RingtonePeer::ID); 

				$criteria->setDbName(self::DATABASE_NAME);

		try {
									$con->begin();
			$pk = BasePeer::doInsert($criteria, $con);
			$con->commit();
		} catch(PropelException $e) {
			$con->rollback();
			throw $e;
		}

		return $pk;
	}

	
	public static function doUpdate($values, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$selectCriteria = new Criteria(self::DATABASE_NAME);

		if ($values instanceof Criteria) {
			$criteria = clone $values; 
			$comparison = $criteria->getComparison(RingtonePeer::ID);
			$selectCriteria->add(RingtonePeer::ID, $criteria->remove(RingtonePeer::ID), $comparison);

		} else { 			$criteria = $values->buildCriteria(); 			$selectCriteria = $values->buildPkeyCriteria(); 		}

				$criteria->setDbName(self::DATABASE_NAME);

		return BasePeer::doUpdate($selectCriteria, $criteria, $con);
	}

	
	public static function doDeleteAll($con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}
		$affectedRows = 0; 		try {
									$con->begin();
			$affectedRows += BasePeer::doDeleteAll(RingtonePeer::TABLE_NAME, $con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	 public static function doDelete($values, $con = null)
	 {
		if ($con === null) {
			$con = Propel::getConnection(RingtonePeer::DATABASE_NAME);
		}

		if ($values instanceof Criteria) {
			$criteria = clone $values; 		} elseif ($values instanceof Ringtone) {

			$criteria = $values->buildPkeyCriteria();
		} else {
						$criteria = new Criteria(self::DATABASE_NAME);
			$criteria->add(RingtonePeer::ID, (array) $values, Criteria::IN);
		}

				$criteria->setDbName(self::DATABASE_NAME);

		$affectedRows = 0; 
		try {
									$con->begin();
			
			$affectedRows += BasePeer::doDelete($criteria, $con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public static function doValidate(Ringtone $obj, $cols = null)
	{
		$columns = array();

		if ($cols) {
			$dbMap = Propel::getDatabaseMap(RingtonePeer::DATABASE_NAME);
			$tableMap = $dbMap->getTable(RingtonePeer::TABLE_NAME);

			if (! is_array($cols)) {
				$cols = array($cols);
			}

			foreach($cols as $colName) {
				if ($tableMap->containsColumn($colName)) {
					$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
					$columns[$colName] = $obj->$get();
				}
			}
		} else {

		}

		$res =  BasePeer::doValidate(RingtonePeer::DATABASE_NAME, RingtonePeer::TABLE_NAME, $columns);
    if ($res !== true) {
        $request = sfContext::getInstance()->getRequest();
        foreach ($res as $failed) {
            $col = RingtonePeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
            $request->setError($col, $failed->getMessage());
        }
    }

    return $res;
	}

	
	public static function retrieveByPK($pk, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$criteria = new Criteria(RingtonePeer::DATABASE_NAME);

		$criteria->add(RingtonePeer::ID, $pk);


		$v = RingtonePeer::doSelect($criteria, $con);

		return !empty($v) > 0 ? $v[0] : null;
	}

	
	public static function retrieveByPKs($pks, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$objs = null;
		if (empty($pks)) {
			$objs = array();
		} else {
			$criteria = new Criteria();
			$criteria->add(RingtonePeer::ID, $pks, Criteria::IN);
			$objs = RingtonePeer::doSelect($criteria, $con);
		}
		return $objs;
	}

} 
if (Propel::isInit()) {
			try {
		BaseRingtonePeer::getMapBuilder();
	} catch (Exception $e) {
		Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
	}
} else {
			require_once 'lib/model/map/RingtoneMapBuilder.php';
	Propel::registerMapBuilder('lib.model.map.RingtoneMapBuilder');
}
